<template>
  <div class="condition">
    <div class="condition-left">
      <el-button-group>
        <el-button :type="buttonNum == 1 ? 'primary' : ''"
                   size="medium"
                   @click="switchButton(1)">本周</el-button>
        <el-button :type="buttonNum == 2 ? 'primary' : ''"
                   size="medium"
                   @click="switchButton(2)">上周</el-button>
        <el-button :type="buttonNum == 3 ? 'primary' : ''"
                   size="medium"
                   @click="switchButton(3)">本月</el-button>
        <el-button :type="buttonNum == 4 ? 'primary' : ''"
                   size="medium"
                   @click="switchButton(4)">上月</el-button>
      </el-button-group>
      <el-date-picker v-model="dateValue"
                      type="daterange"
                      range-separator="~"
                      format="yyyy-MM-dd"
                      value-format='yyyy-MM-dd'
                      start-placeholder="开始日期"
                      end-placeholder="结束日期"
                      @change='dateInput'
                      :picker-options="pickerOptions">
      </el-date-picker>
    </div>
    <div class="condition-right">
      <div class="title">
        <span>统计说明</span>
        <div class="tips-box">
          <span class="iconfont icon-test102"></span>
          <div class="tips">
            <div class="tips-text">
              <p>统计说明:</p>
              <p v-for="(item,index) in 5"
                 :key="index">{{index+1}}、统计为今日的已完成的收款单</p>
            </div>
          </div>
        </div>
      </div>
      <div class="icon">
        <router-link to="#">
          <span class="iconfont icon-test151">&nbsp;导出</span>
        </router-link>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      buttonNum: '3',
      dateValue: '',
      pickerOptions: {
        shortcuts: [{
          text: '今日',
          onClick (picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime())
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '近七日',
          onClick (picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '近三十日',
          onClick (picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            picker.$emit('pick', [start, end])
          }
        }]
      }
    }
  },
  methods: {
    switchButton (value) {
      this.buttonNum = value
    },
    dateInput (e) {
      // console.log(this.conditionData.dateValue)
    }
  }
}
</script>

<style lang="scss" scoped>
.condition {
  display: flex;
  padding: 14px 24px;
  margin-bottom: 12px;
  background-color: #ffffff;
  /deep/ .el-button-group {
    .el-button--medium {
      border-radius: 0;
    }
  }
  .condition-left {
    display: flex;
    align-items: center;
    /deep/ .el-date-editor {
      width: 200px;
      height: 32px;
      padding: 0 12px;
      font-size: 12px;
      color: #333;
      margin-left: 12px;
      border-radius: 2px;
      align-items: right;
      .el-range-input {
        font-size: 12px;
      }
      .el-range__close-icon {
        display: none;
      }
    }
  }
  .condition-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    .title {
      margin-right: 26px;
      font-size: 14px;
      color: #666;
      .tips-box {
        display: inline-block;
        position: relative;
        cursor: pointer;
        line-height: 1;
        .icon-test102 {
          width: 16px;
          height: 16px;
          color: #666;
          background-color: #fff;
          border-radius: 50%;
          margin-left: 4px;
        }
        &:hover {
          .tips {
            display: block;
          }
        }
        .tips {
          display: none;
          position: absolute;
          top: 34px;
          right: -50px;
          z-index: 2;
          font-size: 12px;
          color: #333;
          background: #fff;
          border: 1px solid #e3e3e3;
          border-radius: 2px;
          padding: 10px;
          width: 300px;
          &:before {
            content: "";
            position: absolute;
            top: -6px;
            right: 50px;
            width: 10px;
            height: 10px;
            transform: rotate(-45deg);
            background: #fff;
            border-width: 1px 1px 0 0;
            border-style: solid;
            border-color: #e3e3e3;
          }
          .tips-text {
            color: #999;
            line-height: 2;
          }
        }
      }
    }
    .icon {
      width: 50px;
      margin-left: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      /deep/ span {
        color: #20ade5;
        display: block;
        width: 100%;
        height: 40px;
        line-height: 40px;
        font-size: 14px;
        text-align: left;
        border-bottom: 1px solid #f5f5f5;
        cursor: pointer;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
      }
    }
  }
}
</style>
